package Ex241210;

public class Test {
    public static void main(String[] args){
        java.util.Random rm = new java.util.Random();// 随机数发生器

        System.out.println("=------------------------------------------=\n\n第一个小练习如下：");

        AnimalVirtual[] the_animals = new AnimalVirtual[20];
        for (int x = 0; x < 20; ++x){
            switch(rm.nextInt(3)){
                case 0:
                    the_animals[x] = new Tiger();
                    break;
                case 1:
                    the_animals[x] = new Elephant();
                    break;
                case 2:
                    the_animals[x] = new Fox();
                    break;
                default:
                    the_animals[x] = new Panda();
            }
            the_animals[x].makeSound();
        }

        System.out.println("\n=------------------------------------------=");

        System.out.println("=------------------------------------------=\n\n第二个小练习如下：");

        ShapeVirtual[] the_shapes = new ShapeVirtual[20];
        for (int x = 0; x < 20; ++x){
            switch(rm.nextInt(1)){
                case 0:
                    the_shapes[x] = new Circle(rm.nextDouble(9.0) + 1.0);
                    break;
                default:
                    the_shapes[x] = new Rectangle(rm.nextDouble(9.0) + 1.0, rm.nextDouble(9.0) + 1.0);
            }
            the_shapes[x].cout_area();
        }

        System.out.println("\n=------------------------------------------=");

        System.out.println(("=------------------------------------------=\n\n第三个小练习如下："));

        EmployeeVirtual[] the_employees = new EmployeeVirtual[20];
        for (int x = 0; x < 20; ++x){
            switch(rm.nextInt(1)){
                case 0:
                    the_employees[x] = new SalariedEmployee("****", rm.nextInt(15000) + 5000);
                    break;
                default:
                    the_employees[x] = new HourlyEmployee(
                            "****", rm.nextInt(140) + 60, rm.nextInt(70) + 10);
            }
            the_employees[x].cout_salary();
        }

        System.out.println("\n=------------------------------------------=");
    }
}
